package com.zwj.service.Impl;

import com.zwj.bean.User;
import com.zwj.dao.UserDao;
import com.zwj.dao.impl.UserDaoImpl;
import com.zwj.service.UserService;

/**
 * @author zwj
 * @create 2021-05-12-16:49
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public void registUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return  userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        User user = userDao.queryUserByUsername(username);
        if (user == null)
        {
            return false;
        }else {
            return true;
        }
    }
}
